<template>
  <div>
    <ProductionItem v-for="item in list" :key="item.id" :item="item" />
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex'
import ProductionItem from './ProductionItem'

export default {
  components: {
    ProductionItem
  },
  computed: {
    ...mapState({
      // 获取所有商品
      list: state => state.products.productsList
    })
  },
  methods: {
    ...mapActions('products',[
      'getAllProducts'
    ])
  },
  mounted() {
    // 加载所有商品
    this.getAllProducts();
  }
}
</script>